﻿<UserControl x:Class="MoneyManagerNET.Presentation.View.StockAccountView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="299" d:DesignWidth="362"  Loaded="UserControl_Loaded"
             
             xmlns:vm="clr-namespace:MoneyManagerNET.Presentation.ViewModel;assembly=MoneyManagerNET.Presentation.ViewModel" 
             d:DataContext="{x:Static Member=vm:DesignTimeViewModelSupplier.StockAccount}"
             
             >
    <UserControl.Resources>
    </UserControl.Resources>
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />

        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal">
            <Ellipse Fill="Silver" Width="24" Height="24"/>
            <Label Content="StockInvestments:" FontSize="18"/>
            <Label Content="{Binding Name}" FontSize="18"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" Grid.Row="1">
            <Label Content="  Total: $"/>
            <Label Content="{Binding Total}"/>
            <Label Content="  Invested: $"/>
            <Label Content="{Binding Invested}"/>
            <Label Content="  Gain: $"/>
            <Label Content="{Binding GainLoss}"/>
        </StackPanel>
        <DataGrid AutoGenerateColumns="False" EnableRowVirtualization="True" ItemsSource="{Binding InvestmentCollection}" SelectedItem="{Binding Selected}" Name="stockInvestmentSetDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" Grid.Row="2">
            <DataGrid.Columns>
                <DataGridTextColumn x:Name="heldAtColumn" Binding="{Binding Path=HeldAt.Name}" Header="Held at" Width="SizeToHeader" />

                <DataGridTextColumn x:Name="stockNameColumn" Binding="{Binding Path=StockName}" Header="Share Name" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="stockCountColumn" Binding="{Binding Path=StockCount}" Header="Number of shares" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="gainLossColumn" Binding="{Binding Path=GainLoss}" Header="Gain/Loss" Width="SizeToHeader" />

                <DataGridTextColumn x:Name="valueColumn" Binding="{Binding Path=Value}" Header="Value" Width="SizeToHeader" />


                <DataGridTextColumn x:Name="currentPriceColumn" Binding="{Binding Path=CurrentPrice}" Header="Current Price" Width="SizeToHeader" />
                
                <DataGridTemplateColumn x:Name="dateColumn" Header="Date" Width="SizeToHeader">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <DatePicker SelectedDate="{Binding Path=Date, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
        
        <StackPanel Orientation="Horizontal" Grid.Row="3">
            <Button Content="New" Command="{Binding NewCommand}" >
                <Button.Foreground>
                    <SolidColorBrush Color="{DynamicResource Green}"/>
                </Button.Foreground>
            </Button>
            <Button Content="Edit" Command="{Binding EditCommand}">
                <Button.Foreground>
                    <SolidColorBrush Color="{DynamicResource Edit}"/>
                </Button.Foreground>
            </Button>
            <Button Content="Delete" Command="{Binding DeleteCommand}">
                <Button.Foreground>
                    <SolidColorBrush Color="{DynamicResource Red}"/>
                </Button.Foreground>
            </Button>
            <Button Content="Refresh"/>
            <Button Content="Settings"/>

        </StackPanel>
    </Grid>
</UserControl>
